<template>
  <div class="about">
    <van-form @submit="onSubmit" @failed="onFailed">
      <van-field
          v-model="username"
          name="username"
          label="用户名"
          placeholder="用户名"
          :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
          v-model="password"
          type="password"
          name="password"
          label="密码"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">提交</van-button>
      </div>
    </van-form>
    <van-field name="rate" label="评分">
      <template #input>
        <van-rate v-model="rate" />
      </template>
    </van-field>
  </div>
</template>

<script>
export default {
  data() {

    return {
      username: '',
      password: '',
      rate:3,
    };
  },
  methods: {
    onSubmit(values) {
      console.log('submit', values);
    },
    onFailed(errorInfo){
      console.log("表单验证未通过,提交失败")
      console.log("提交的信息为:");
      console.log(errorInfo.values)
      console.log("失败的原因为:");
      console.log(errorInfo.errors)
    },
  },
};

</script>
